// 引入 Mock
const { Random } = require('mockjs')
function getMockByProps (props) {
  const propMock = {}
  if (Array.isArray(props)) {
    props.forEach(function (key) {
      propMock[key] = Random.string(4, 10)
    })
  } else {
    for (const key in props) {
      const obj = props[key]
      if (obj.default) {
        propMock[key] = obj.default
      } else if (obj.type === 'number') {
        propMock[key] = Random.integer(1, 10)
      } else {
        propMock[key] = Random.string(4, 10)
      }
    }
  }
  return propMock
}
module.exports = getMockByProps
